﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Store.DateModel;

public partial class Pages_WebControls_PopularItems : System.Web.UI.UserControl
{
    private int numberOfProducts = 5;
    private StoreApplicationService sas = new StoreApplicationService();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            var query = sas.GetMostPopularProducts(numberOfProducts);

            RepeaterItemsList.DataSource = query;
            RepeaterItemsList.DataBind();
            
        }
        catch (Exception exp)
        {
            throw new Exception("ERROR: Control Unable to Load Popular Items - " + exp.Message.ToString(), exp);
        }
    }

    public int NumberOfProducts
    {
        get { return numberOfProducts; }
        set { numberOfProducts = value; }
    }
}